package com.laoxu.java.collection;

import java.util.ArrayList;

/**
 * @author laoxu
 * @create 2018-01-28
 **/
public class ArrayListExample {
    public static void main(String args[]) {
      /*Creation of ArrayList: I'm going to add String
       *elements so I made it of string type */
        ArrayList<String> obj = new ArrayList<String>();

	  /*This is how elements should be added to the array list*/
        obj.add("Ajeet");
        obj.add("Harry");
        obj.add("Chaitanya");
        obj.add("Steve");
        obj.add("Anuj");

	  /* Displaying array list elements */
        System.out.println("Currently the array list has following elements:"+obj);

	  /*Add element at the given index*/
        obj.add(0, "Rahul");
        obj.add(1, "Justin");

	  /*Remove elements from array list like this*/
        obj.remove("Chaitanya");
        obj.remove("Harry");

        System.out.println("Current array list is:"+obj);

	  /*Remove element from the given index*/
        obj.remove(1);

        System.out.println("Current array list is:"+obj);
    }
}
